package com.wslNB.goods.service.impl;

import com.wslNB.goods.dao.SpecMapper;
import com.wslNB.goods.pojo.Spec;
import com.wslNB.goods.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * spec 服务类
 */
@Service
public class SpecServiceImpl implements SpecService {

    @Autowired
    private SpecMapper specMapper;


    /**
     * 根据分类名称查询规格表
     * @param categoryName
     * @return
     */
    @Override
    public List<Map> findListByCategoryName(String categoryName) {

        List<Map> listByCategoryName = specMapper.findListByCategoryName(categoryName);
        for (Map map : listByCategoryName) {
            String options = (String) map.get("OPTIONS");
            String[] strings = options.split(",");
            map.put("OPTIONS",strings);
        }

        return listByCategoryName;
    }
}
